package ar.edu.itba.twiteros.util;

import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.http.AccessToken;
import twitter4j.http.RequestToken;

public class TwitterUtil {
	
	private static String consumerKey="k7o1ugNpJ5XNH8iKrDlQ";
	
	private static String consumerSecret="BgxyJ3H4pwSZ5fxGNMABbt3Ss8J8c5ypVP6FchxA3cw";
	
	private Twitter twitter;
	
	private RequestToken requestToken;
	
	private String token=null;
	
	private String tokenSecret=null;
	
	private AccessToken accessToken;
	
	public TwitterUtil() throws TwitterException{
		twitter = new Twitter();
		twitter.setOAuthConsumer(consumerKey, consumerSecret);
		requestToken = twitter.getOAuthRequestToken();
	}

	public void initTokens() throws TwitterException{
		token= requestToken.getToken();
		tokenSecret= requestToken.getTokenSecret();
		accessToken =twitter.getOAuthAccessToken(token, tokenSecret);
		twitter.setOAuthAccessToken(accessToken);
	}
	
	public String getTokenSercret() {
		return tokenSecret;
	}



	public String getToken() {
		return token;
	}



	public static String getConsumerKey() {
		return consumerKey;
	}

	public static void setConsumerKey(String consumerKey) {
		TwitterUtil.consumerKey = consumerKey;
	}

	public static String getConsumerSecret() {
		return consumerSecret;
	}

	public static void setConsumerSecret(String consumerSecret) {
		TwitterUtil.consumerSecret = consumerSecret;
	}

	public Twitter getTwitter() {
		return twitter;
	}

	public void setTwitter(Twitter twitter) {
		this.twitter = twitter;
	}

	public String getAuthUrl(){
		return requestToken.getAuthenticationURL();
	}
}
